package com.tvshows.front.factory;

import org.eclipse.swt.widgets.Composite;

import com.tvshows.front.ui.FrontUI;
import com.tvshows.front.ui.main.MainUI;
import com.tvshows.front.view.dialog.ActionsView;
import com.tvshows.front.view.dialog.DialogLogView;
import com.tvshows.front.view.dialog.DialogOptionsView;
import com.tvshows.front.view.favorite.FavoriteView;
import com.tvshows.front.view.favorite.ListCompositeFavoriteView;
import com.tvshows.front.view.favorite.UpsideCompositeFavoriteView;
import com.tvshows.front.view.main.MainView;
import com.tvshows.front.view.menu.MenuView;
import com.tvshows.front.view.recap.RecapView;
import com.tvshows.front.view.recap.TableCompositeRecapView;
import com.tvshows.front.view.recap.UpsideCompositeRecapView;
import com.tvshows.front.view.refresh.RefreshView;

/**
 * @author tMidy
 * <p>
 * Factory that creates the main views
 * </p>
 */
public class ViewFactory
{

    /**
     * The main view (Singleton)
     */
    static MainUI mainView;

    /**
     * Creates or returns the ui desired
     * 
     * @param type the {@link TypeUI}
     * @return the view desired
     */
    public static FrontUI getUI( TypeUI type )
    {
        FrontUI view = null;

        switch ( type )
        {
            case FAVORITE_VIEW:
                view = new FavoriteView( mainView.getShell(), 0 );
                break;
            case MAIN_VIEW:
                mainView = new MainView();
                return mainView;
            case ACTIONS_VIEW:
                view = new ActionsView();
                break;
            case OPTION_VIEW:
                view = new DialogOptionsView( (Composite) mainView.getFavoriteView(), 0 );
                break;
            case LOG_VIEW:
                view = new DialogLogView( (Composite) mainView.getFavoriteView(), 0 );
                break;
            case LIST_COMPOSITE_FAVORITE_VIEW:
                view = new ListCompositeFavoriteView( (Composite) mainView.getFavoriteView(), 0 );
                break;
            case TABLE_COMPOSITE_RECAP_VIEW:
                view = new TableCompositeRecapView( (Composite) mainView.getRecapView(), 0 );
                break;
            case UPSIDE_COMPOSITE_FAVORITE_VIEW:
                view = new UpsideCompositeFavoriteView( (Composite) mainView.getFavoriteView(), 0 );
                break;
            case RECAP_VIEW:
                view = new RecapView( mainView.getShell(), 0 );
                break;
            case UPSIDE_COMPOSITE_RECAP_VIEW:
                view = new UpsideCompositeRecapView( (Composite) mainView.getRecapView(), 0 );
                break;
            case REFRESH_VIEW:
                view = new RefreshView( (Composite) mainView.getRecapView().getTableComposite(), 0 );
                break;
            case MENU_VIEW:
                return new MenuView();
            default:
                break;
        }
        return view;
    }

}
